#include "stdafx.h"
#include "net/MailRecipient.hpp"
#include <algorithm>

NET_NAMESPACE_BEGIN

CMailRecipient::CMailRecipient() : m_type(PRIMARY_RECIPIENT)
{
}

CMailRecipient::CMailRecipient(const CMailRecipient& recipient)
	: m_address(recipient.m_address),
	m_realName(recipient.m_realName),
	m_type(recipient.m_type)
{
}

CMailRecipient::CMailRecipient(RecipientType type, const std::string& address)
	: m_address(address),
	m_type(type)
{
}

CMailRecipient::CMailRecipient(RecipientType type, const std::string& address, const std::string& realName)
	: m_address(address),
	m_realName(realName),
	m_type(type)
{
}

CMailRecipient::~CMailRecipient()
{
}

CMailRecipient& CMailRecipient::operator = (const CMailRecipient& recipient)
{
	if (this != &recipient)
	{
		CMailRecipient tmp(recipient);
		swap(tmp);
	}
	return *this;
}

void CMailRecipient::swap(CMailRecipient& recipient)
{
	std::swap(m_type, recipient.m_type);
	std::swap(m_address, recipient.m_address);
	std::swap(m_realName, recipient.m_realName);
}

void CMailRecipient::setType(RecipientType type)
{
	m_type = type;
}

void CMailRecipient::setAddress(const std::string& address)
{
	m_address = address;
}

void CMailRecipient::setRealName(const std::string& realName)
{
	m_realName = realName;
}

CMailRecipient::RecipientType CMailRecipient::getType() const
{
	return m_type;
}

const std::string& CMailRecipient::getAddress() const
{
	return m_address;
}

const std::string& CMailRecipient::getRealName() const
{
	return m_realName;
}


NET_NAMESPACE_END
